package com.ruirenyun.service.impl;

import com.ruirenyun.entity.AdPosition;
import com.ruirenyun.mapper.AdPositionMapper;
import com.ruirenyun.service.AdPositionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告位管理表(AdPosition)表服务实现类
 *
 * @author makejava
 * @since 2021-04-20 11:47:10
 */
@Service("adPositionService")
public class AdPositionServiceImpl implements AdPositionService {
    @Resource
    private AdPositionMapper adPositionMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param adId 主键
     * @return 实例对象
     */
    @Override
    public AdPosition getById(Long adId) {
        return this.adPositionMapper.selectByPrimaryKey(adId);
    }

    /**
     * 查询多条数据
     *
     * @param adPosition 对象
     * @return 对象列表
     */
    @Override
    public List<AdPosition> getList(AdPosition adPosition) {
        return this.adPositionMapper.getList(adPosition);
    }

    /**
     * 新增数据
     *
     * @param adPosition 实例对象
     * @return 实例对象
     */
    @Override
    public AdPosition insertSelective(AdPosition adPosition) {
        this.adPositionMapper.insertSelective(adPosition);
        return adPosition;
    }

    /**
     * 修改数据
     *
     * @param adPosition 实例对象
     * @return 实例对象
     */
    @Override
    public AdPosition updateByPrimaryKeySelective(AdPosition adPosition) {
        this.adPositionMapper.updateByPrimaryKeySelective(adPosition);
        return this.getById(adPosition.getAdId());
    }

    /**
     * 通过主键删除数据
     *
     * @param adId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long adId) {
        return this.adPositionMapper.deleteByPrimaryKey(adId) > 0;
    }
}
